package lu.med.praxiswahl.wahlumed.client.wclient;

import java.awt.AWTEvent;
import java.awt.EventQueue;
import java.awt.event.KeyEvent;

/**
 * 
 * @author Lars Roth
 * 
 */
public class ExtraEventQueue extends EventQueue {

	private String screensaver = "";

	public ExtraEventQueue(String screensaver) {
		this.screensaver = screensaver;
		
	}

	@Override
	protected void dispatchEvent(AWTEvent event) {
		if (event instanceof KeyEvent) {
			KeyEvent keyEvent = (KeyEvent) event;
			if (keyEvent.getID() == KeyEvent.KEY_PRESSED
					&& (keyEvent).getKeyCode() == KeyEvent.VK_ESCAPE) {
				try {
					Runtime.getRuntime().exec(screensaver + " /s");
				} catch (Exception ee) {
				}
			}
		}
		super.dispatchEvent(event);
	}
}
